﻿using BUGCOME.Model.File.Dto;
using System.ComponentModel.DataAnnotations.Schema;


namespace BUGCOME.Model.File
{
    /// <summary>
    /// 文件基础信息实体类，用于存储文件的核心属性信息
    /// </summary>
    [Table("fileBase")]
    [Tenant("5")]
    public class FileBase
    {
        public FileBase()
        {

        }
        public FileBase(string originFileName, string fileName, string ext, long fileSize, string storePath, long CreateId, string CreateBy)
        {
            FileUrl = storePath;
            RealName = originFileName;
            Name = fileName;
            FileExt = ext;
            FileSize = fileSize;
            this.CreateId = CreateId;
            this.CreateBy = CreateBy;
            CreateTime = DateTime.Now;
        }
        /// <summary>
        /// 文件ID（雪花ID）
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
        [JsonConverter(typeof(ValueToStringConverter))]
        public long Id { get; set; }

        /// <summary>
        /// 文件原名
        /// </summary>
        public string RealName { get; set; }

        /// <summary>
        /// 存储文件名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 文件存储地址
        /// </summary>
        public string FileUrl { get; set; }

        /// <summary>
        /// 存储类型（1=本地，2=阿里云OSS，3=AWS S3）
        /// </summary>
        public int StorageType { get; set; }

        /// <summary>
        /// 仓库位置
        /// </summary>
        public int StoragePath { get; set; }

        /// <summary>
        /// 访问地址
        /// </summary>
        public string AccessUrl { get; set; }

        /// <summary>
        /// 文件哈希（去重）
        /// </summary>
        public string FileHash { get; set; }

        /// <summary>
        /// 文件大小（字节）
        /// </summary>
        public long FileSize { get; set; }

        /// <summary>
        /// MIME类型
        /// </summary>
        public string FileType { get; set; }

        /// <summary>
        /// 文件扩展名
        /// </summary>
        public string FileExt { get; set; }

        /// <summary>
        /// 可见性（1=公开免费，2=按次收费，3=会员专属）
        /// </summary>
        public int Visibility { get; set; }

        /// <summary>
        /// 状态（0=定时删除，1=正常，2=禁用）
        /// </summary>
        public int Status { get; set; } = 1;

        /// <summary>
        /// 创建者ID
        /// </summary>
        public long CreateId { get; set; }

        /// <summary>
        /// 创建者名称
        /// </summary>
        public string CreateBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 修改人ID
        /// </summary>
        public long UpdateId { get; set; }

        /// <summary>
        /// 修改人名称
        /// </summary>
        public string UpdateBy { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        // 关联子表（导航属性）
        [SugarColumn(IsIgnore = true)]
        [ExcelIgnore]
        public FileFree FileFree { get; set; } = new FileFree();

        [SugarColumn(IsIgnore = true)]
        [ExcelIgnore]
        public FilePayPerDownload FilePayPerDownload { get; set; } = new FilePayPerDownload();

        [SugarColumn(IsIgnore = true)]
        [ExcelIgnore]
        public FileMember FileMember { get; set; } = new FileMember();


    }
}